package NovelBar.service;

import NovelBar.entity.Goods;
import NovelBar.mapper.GoodsMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class GoodsService {
	// ����springboot��ע���Ϊһ��springbean
	@Autowired
	private GoodsMapper goodsMapper;
	// ͨ���̼ҹ�����Ʒ
	public List<Goods> loadGoodsByBusiness(String business) {
		return goodsMapper.loadGoodsByBusiness(business);
	}
	// ��ȡ������Ʒ
	public List<Goods> loadAllGoods() {
		// TODO Auto-generated method stub
		return goodsMapper.loadAllGoods();
	}
	// �����Ʒ
	public void addGoods(Goods goods) {
		// TODO Auto-generated method stub
		if (goods.getIml().equals("")) {
			goods.setIml("//g-search2.alicdn.com/img/bao/uploaded/i4/i3/1890711916/O1CN01tTGJbb1Q1ZRzMllIT_!!0-item_pic.jpg_580x580Q90.jpg_.webp");
		}
		goodsMapper.addGoods(goods);
	}
	// ͨ����Ʒ���ƣ��̼ң��۸������Ʒ
	public List<Goods> loadGoodsByRequire(String goodsNameRequire, String business, int priceMin, int priceMax) {
		// TODO Auto-generated method stub
		return goodsMapper.loadGoodsByRequire(goodsNameRequire, business, priceMax, priceMin);
	}
}
